package com.ado.abyss.core.manager.impl;

import com.ado.abyss.core.dal.dao.SysDictMapper;
import com.ado.abyss.core.dal.model.SysDict;
import com.ado.abyss.core.manager.SysDictManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author adonais
 * @date 2020/7/9
 * @description SysDictManagerImpl
 **/
@Service(value = "sysDictManager")
public class SysDictManagerImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictManager {

    @Autowired
    private SysDictMapper sysDictMapper ;

    @Override
    public List<SysDict> findByLabel(String label) {
        return sysDictMapper.findByLabel(label);
    }

    @Override
    public List<SysDict> findAll() {
        return sysDictMapper.findAll();
    }

    @Override
    @Transactional
    public boolean deleteByIds(List<Long> Ids) {
        boolean flag = false ;
        int result = sysDictMapper.deleteByIds(Ids) ;
        if (result == 1) {
            flag = true ;
        }
        return flag;
    }

    @Override
    @Transactional
    public boolean saveDict(SysDict record) {
        boolean flag = false ;
        int result = sysDictMapper.insertSelective(record) ;
        if( result == 1) {
            flag = true ;
        }
        return flag;
    }
}
